import { _decorator, Component, Node, Vec3 } from 'cc';
import { AddUsePlayerGoodsAPI } from '../../GameAPI';
import GameConst, { NPrefabKeys } from '../../GameConst';
import { EventArgeType } from '../../ngame/actions/client/CNWorld2Action';
import SNWorld2Action from '../../ngame/actions/service/SNWorld2Action';
import NSyncServer from '../../ngame/sync/NSyncServer';
import NWorld2Component from '../../ngame/sync/NWorld2Component';
const { ccclass, property } = _decorator;

@ccclass('ISceneController')
export class ISceneController extends NWorld2Component{

    //摆放树木
    async onPlaceTrees(playerId:string,pos:Vec3){

        console.log("摆放树木");

        let data = await AddUsePlayerGoodsAPI(playerId,NPrefabKeys.树木,-1);
        console.log("摆放树木",data);

        if(data){
            NSyncServer.getIns().addNode(NPrefabKeys.树木,pos);
            SNWorld2Action.nRelayEvent(playerId,{
                type:EventArgeType.Tips,
                data:"摆放成功"
            })
        }else{
            SNWorld2Action.nRelayEvent(playerId,{
                type:EventArgeType.Tips,
                data:"摆放失败"
            })
        }
    }

}


